package com.mlf.abstractFactory.spring.peripheral;

import com.mlf.abstractFactory.demo.peripheral.GamingPeripheralFactory;
import com.mlf.abstractFactory.demo.peripheral.OfficePeripheralFactory;
import com.mlf.abstractFactory.demo.peripheral.PeripheralFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AbstractPeripheralConfig {
    @Bean
    @ConditionalOnProperty(name = "peripheral.type", havingValue = "game")
    public PeripheralFactory gamePeripheralFactory() {
        return new GamingPeripheralFactory();
    }

    @Bean
    @ConditionalOnProperty(name = "peripheral.type", havingValue = "office")
    public PeripheralFactory officePeripheralFactory() {
        return new OfficePeripheralFactory();
    }

}
